package com.kevin.util.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.kevin.util.PassUtil;
/**
 * 
  * @ClassName: PassUtilTag 
  * @Description: 密码工具类
  * @author 吕凯
  * @date 2012-6-18 上午09:08:08 
  *
 */
public class PassUtilTag  extends TagSupport{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 134546456L;
	private Integer type=0;
	private String pass="";
	
	
	
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public String getPass() {
		return pass;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}

	@Override
	public int doEndTag() throws JspException {
		// TODO Auto-generated method stub
		
		try {	
			String newStr = "";
			if(!pass.equals("")){
				if(type == 1){
					newStr = PassUtil.encryptPass(pass);
				}else{
					newStr = PassUtil.decryptPass(pass);			
				}				
			}
			pageContext.getOut().print(newStr);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return SKIP_BODY;
	}

	@Override
	public int doStartTag() throws JspException {
		// TODO Auto-generated method stub
		return EVAL_PAGE;
	} 

}
